//
//  PFMessageHUD.h
//  PetsCare
//
//  Created by Latsen on 2018/7/2.
//  Copyright © 2018年 Latsen. All rights reserved.
//

#import <UIKit/UIKit.h>

#define     PFRGBColor(r, g, b)           [UIColor colorWithRed:(r)/255.0f green:(g)/255.0f blue:(b)/255.0f alpha:1.0]

#define IPHONE_X (SCREEN_WIDTH == 375.f && SCREEN_HEIGHT == 812.f ? YES : NO)

#define SCREEN_WIDTH [UIScreen mainScreen].bounds.size.width
#define SCREEN_HEIGHT [UIScreen mainScreen].bounds.size.height
#define SCREEN_SIZE [UIScreen mainScreen].bounds.size
#define SCREEN_BOUNDS [UIScreen mainScreen].bounds

//状态栏、导航栏高度
#define UI_TABEXTRA_HEIGHT (IPHONE_X ? 34.f : 0)
#define UI_TABBAR_HEIGHT (UI_TABEXTRA_HEIGHT + 49.f)
#define STATUS_BAR_HEIGHT (IPHONE_X ? 44.f : 20.f)
#define NAVIGATION_BAR_HEIGHT (44)
#define STATUS_NAVI_HEIGHT ((STATUS_BAR_HEIGHT) + (NAVIGATION_BAR_HEIGHT))

/**
 场景: 如果有NetworkError或者带Cancel按钮的提示，必须显示在UIWindow图层上
 测试：当UIWindow上有提示，系统Alert弹窗后Cancel，是否存在？
 场景：当有一条新的Normal消息提示
 */

typedef enum : NSUInteger {
    ///弹窗
    PFAnimationTypePop,
    ///下滑
    PFAnimationTypeSlide,
    ///渐变
    PFAnimationTypeFade
    
} PFAnimationType;

typedef enum : NSUInteger {
    ///自动隐藏 (Default 1.8s)
    HUDStayTypeAuto,
    ///网络错误提示,一直停留 (superView == UIWindow)
    HUDStayTypeNetworkError,
    ///含x按钮的error hud (superView == UIWindow)
    HUDStayTypeErrorWithClickIcon,
    
} HUDStayType;

typedef enum : NSUInteger {
    /** 普通状态 */
    PFMessageResultNormal,
    /** 成功状态 */
    PFMessageResultSuccess,
    /** 普通错误状态 */
    PFMessageResultError,
    /** 红色错误 x 状态 */
    PFMessageResultAlwaysErrorClick,
    /** 红色错误长期保留状态 */
    PFMessageResultAlwaysErrorShow
    
} PFMessageResult;

@interface PFMessageConfig : NSObject

@property (nonatomic, assign) PFAnimationType animationType;
@property (nonatomic, assign) HUDStayType stayType;
@property (nonatomic, assign) NSTimeInterval autoDismissTime;
/** 允许2个HUD */
@property (nonatomic, assign) BOOL enableHUDNumbers;

@property (nonatomic, assign) CGFloat ftopSpace;
@property (nonatomic, assign) CGFloat fbottomSpace;
@property (nonatomic, assign) CGFloat fleftSpace;
@property (nonatomic, assign) CGFloat frightSpace;


@end

@interface PFMessageHUD : UIView

/** Default stayType = auto */
+ (BOOL)showMessage:(NSString *)text inView:(UIView *)view animated:(PFAnimationType)animated;

/** Default stayType = auto */
+ (BOOL)showError:(NSString *)text inView:(UIView *)view animated:(PFAnimationType)animatied needClick:(BOOL)needClick;

/** 扩展以后区分 info,succ,error 状态hud */
+ (BOOL)showSuccess:(NSString *)text inView:(UIView *)view animated:(PFAnimationType)animatied;

/** Default stayType = auto */
+ (BOOL)showMessage:(NSString *)text inView:(UIView *)view stayType:(HUDStayType)type;

/** Default stayType = auto */
+ (BOOL)showError:(NSString *)text inView:(UIView *)view stayType:(HUDStayType)type;

/** 扩展以后区分 info,succ,error 状态hud */
+ (BOOL)showSuccess:(NSString *)text inView:(UIView *)view stayType:(HUDStayType)type;

/** all */
+ (BOOL)showMessage:(NSString *)text inView:(UIView *)view animated:(PFAnimationType)animated stayType:(HUDStayType)type afterDelay:(NSTimeInterval)delay;

+ (BOOL)hideHUDInView:(UIView *)view;

/** 实例方法 */
- (void)showAnimated:(BOOL)animate;

- (void)hideAnimated:(BOOL)animated;

@end

/** 普通消息对象 */
@interface PFMSGObject : NSObject

@property (nonatomic, strong) NSString *text;
@property (nonatomic, assign) NSTimeInterval delayTime;

@property (nonatomic, assign) HUDStayType stayType;
@property (nonatomic, assign) PFAnimationType animationType;
@property (nonatomic, assign) PFMessageResult messageType;

@end



